package com.example.android2019.ch3;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.android2019.R;

public class Ch3StorageActivity extends AppCompatActivity {
    Button btn1, btn2, btn3, btn4, btn5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ch3_storage);

        inti();

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case R.id.ch3_storage_btn1:
                        sp();
                        break;
                    case R.id.ch3_storage_btn2:
                        outer();
                        break;
                    case R.id.ch3_storage_btn3:
                        inner();
                        break;
                    case R.id.ch3_storage_btn4:
                        qq();
                        break;
                    case R.id.ch3_storage_btn5:
                        sqlite();
                        break;
                }
            }
        };
        btn1.setOnClickListener(listener);
        btn2.setOnClickListener(listener);
        btn3.setOnClickListener(listener);
        btn4.setOnClickListener(listener);
        btn5.setOnClickListener(listener);

        /*获取传递的数据*/
        Intent intent = this.getIntent();
        String a = intent.getStringExtra("test");
        Toast.makeText(this, a, Toast.LENGTH_SHORT).show();
    }

    private void inti() {
        btn1=findViewById(R.id.ch3_storage_btn1);
        btn2=findViewById(R.id.ch3_storage_btn2);
        btn3=findViewById(R.id.ch3_storage_btn3);
        btn4=findViewById(R.id.ch3_storage_btn4);
        btn5=findViewById(R.id.ch3_storage_btn5);
    }

    private void sqlite() {
        /*跳转*/
        Intent intent = new Intent(Ch3StorageActivity.this, Ch3SQLiteActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void qq() {
        /*跳转*/
        Intent intent = new Intent(Ch3StorageActivity.this, Ch3QQActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void inner() {
        /*跳转*/
        Intent intent = new Intent(Ch3StorageActivity.this, Ch3FileInnerActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void outer() {
        /*跳转*/
        Intent intent = new Intent(Ch3StorageActivity.this, Ch3FileOuterActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }

    private void sp() {
        /*跳转*/
        Intent intent = new Intent(Ch3StorageActivity.this, Ch3SpActivity.class);
        /*传递数据*/
        intent.putExtra("test", "tz");
        startActivity(intent);
    }
}
